package com.zmzncs.lmtc.module.promotion.controller;


import com.zmzncs.lmtc.common.pojo.Rest;
import com.zmzncs.lmtc.common.util.JsonUtil;
import com.zmzncs.lmtc.common.util.RestUtil;
import com.zmzncs.lmtc.module.promotion.pojo.duration_rule_fee_scale.DurationRuleFeeScaleDTO;
import com.zmzncs.lmtc.module.promotion.pojo.duration_rule_fee_scale.DurationRuleFeeScaleVO;
import com.zmzncs.lmtc.module.promotion.service.DurationRuleFeeScaleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 任建波
 * @since 2020-08-12
 */
@Api(tags = "时长规则的收费标准")
@RestController
@RequestMapping("/promotion/duration-rule-paytype")
public class DurationRulePaytypeController {

    @Autowired
    DurationRuleFeeScaleService durationRuleFeeScaleService;

    @ApiOperation(value = "根据停车场id查询支付规则")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", name = "token", value = "请求头token", required = true),
            @ApiImplicitParam(paramType="query", name="parkId", value="停车场id", required = true),
    })
    @GetMapping(value = "getDurationRulePaytypeByParkId")
    public Rest<List<DurationRuleFeeScaleVO>> getDurationRulePaytypeByParkId(String parkId) {
        List<DurationRuleFeeScaleDTO> durationRuleFeeScaleDTOList = durationRuleFeeScaleService.getDurationRuleFeeScaleByParkId(parkId);
        List<DurationRuleFeeScaleVO> durationRuleFeeScaleVOList = JsonUtil.listTransform(durationRuleFeeScaleDTOList, DurationRuleFeeScaleVO.class);
        //  该停车场还没有开启VIP服务
        if(durationRuleFeeScaleVOList.size() == 0){
            return RestUtil.warning("该停车场还没有开启VIP服务");
        } else {
            return RestUtil.success(durationRuleFeeScaleVOList);
        }
    }

}

